package com.group.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.group.pojo.TbMenu;
import com.group.service.MenuService;

/**
 * menu控制器
 * @author caoyanan
 * @time 2017年10月18日下午1:09:45
 */
@Controller
@RequestMapping("/menu")
public class MenuController {

	@Autowired
	private MenuService menuService;
	
	@RequestMapping("page.action")
	public String page() {
		return "admin/menu/menu";
	}
	
	@RequestMapping("updateSort.action")
	public String updateSort() {
		return "admin/menu/update-sort";
	}
	
	@RequestMapping("query.action")
	@ResponseBody
	public List<TbMenu> query(TbMenu menu){
		List<TbMenu> list = menuService.query(menu);
		return list;
	}
	
	@RequestMapping("update.action")
	@ResponseBody
	public Map<String, String> update(TbMenu menu){
		Map<String, String> map = menuService.update(menu);
		return map;
	}
	
	@RequestMapping("updateSortSave.action")
	@ResponseBody
	public Map<String, String> updateSortSave(@RequestParam(value = "menuId[]") String[] menuId){
		Map<String, String> map = menuService.updateSort(menuId);
		return map;
	}
	
	@RequestMapping("isExistSubMenu.action")
	@ResponseBody
	public String isExistSubMenu(TbMenu menu) {
		String result = menuService.isExistSubMenu(menu);
		return result;
	}
}
